<div>
    <div id="bzcjFuZhuRenYuanDiv" style="width:100%;height: 100%;overflow: auto">
        <button style="width: 100%;text-align: left" class="layui-btn"><span id="bzcjFuZhuRenYuanFzName" style="font-size: 18px"></span>综合绩效计算表<span style="color: #86b9e0">（效率奖金 +损耗率奖金+规范化奖金+质量奖金）*出勤率+发现异常奖金-违规扣款</span></button>
        <table id="bzFuZhuRenYuanTable"></table>
        <div id="bzFuZhuRenYuanTableToolbar" style="display: none;">
            <div style="width: 350px;">
                <a class="easyui-linkbutton c1" style="height: 90%"  data-options="plain:true" onclick="javaScript:$('#bzFuZhuRenYuanTable').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
                <a class="easyui-linkbutton"  data-options="plain:true">|</a>
                <a class="easyui-linkbutton c6" style="height: 90%"  data-options="plain:true" onClick="javaScript:$('#bzFuZhuRenYuanTable').edatagrid('addRow')"><i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>新增</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c5" style="height: 90%"  data-options="plain:true" onclick="javaScript:$('#bzFuZhuRenYuanTable').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c4" style="height: 90%"  data-options="plain:true" onClick="bzFuZhuRenYuanTableInit()"><i class="fa fa-repeat fa-fw" aria-hidden="true"></i>刷新</a>
            </div>
        </div>
        <!-- 辅助组长表 -->
        <button style="width: 100%;text-align: left" class="layui-btn"><span id="bzcjFuZhuRenYuanZzName" style="font-size: 18px"></span>综合绩效计算表<span style="color: #86b9e0">（效率奖金 +损耗率奖金+规范化奖金+质量奖金）*出勤率+发现异常奖金-违规扣款</span><span style="color:red">[绩效奖金标准是该组所有辅助人员的最终绩效奖金平均值*1.2]</span></button>
        <table id="bzFuZhuZuZhangTable"></table>
        <div id="bzFuZhuZuZhangTableToolbar" style="display: none;">
            <div style="width: 350px;">
                <a class="easyui-linkbutton c1" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#bzFuZhuZuZhangTable').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c6" data-options="plain:true" style="height: 90%" onClick="javaScript:$('#bzFuZhuZuZhangTable').edatagrid('addRow')"><i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>新增</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c5" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#bzFuZhuZuZhangTable').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c4" data-options="plain:true" style="height: 90%" onClick="bzFuZhuZuZhangTableInit()"><i class="fa fa-repeat fa-fw" aria-hidden="true"></i>刷新</a>
            </div>
        </div>
    <!-- 清洁工、搬运工表 -->
        <button  style=" width:100%;text-align: left" class="layui-btn"><span id="bzcjFuZhuRenYuanQtName" style="font-size: 18px">清洁工、搬运工等</span>综合绩效计算表<span style="color: #86b9e0">（效率奖金 +损耗率奖金+规范化奖金+质量奖金）*出勤率+发现异常奖金-违规扣款</span><span style="color:red">[绩效奖金标准是所有辅助人员的最终绩效奖金平均值]</span></button>
        <table id="bzFuZhuZaGongTable"></table>
        <div id="bzFuZhuZaGongTableToolbar" style="display: none;">
            <div style="width: 350px">
                <a class="easyui-linkbutton c1" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#bzFuZhuZaGongTable').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c6" data-options="plain:true" style="height: 90%" onClick="javaScript:$('#bzFuZhuZaGongTable').edatagrid('addRow')"><i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>新增</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c5" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#bzFuZhuZaGongTable').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>
                <a class="easyui-linkbutton" data-options="plain:true">|</a>
                <a class="easyui-linkbutton c4" data-options="plain:true" style="height: 90%" onClick="bzZaGongTableInit()"><i class="fa fa-repeat fa-fw" aria-hidden="true"></i>刷新</a>
            </div>
        </div>
    </div>
<script src="/js/jxAssess/bzcj/bzcjFuZhuRenYuan.js"></script>
<script>
    $("#bzcjFuZhuRenYuanFzName").text(JX_BZCJ_FUZHURENYUAN)
    $("#bzcjFuZhuRenYuanZzName").text(JX_BZCJ_FUZHUZUZHANG)

    //初始化辅助人员的表
    bzFuZhuRenYuanTableInit();

    //【辅助组长综合绩效计算表】初始化辅助组长绩效表
    bzFuZhuZuZhangTableInit();

    //杂工（清洁工、搬运工）
   bzZaGongTableInit()

    //生产效率奖金------------------------------------------------------------------------------------------------
    //辅助人员-绩效奖金标准触发事件
    function baoZhuangCheJianFuZhuRenYuanProductivity() {
        //生产效率B:当月所有产线所有工单总计划工时/当月所有产线所有工单实际生产工时*100%。
        //获取产线生产效率
        var teamEfficiency = getEditObjectFuZhu("teamEfficiency").textbox("getValue");
        //获取备料准确及时率
        var accuracyImeliness = getEditObjectFuZhu("accuracyImeliness").textbox("getValue");
        //赋值绩效奖金标准基数
        var rEfficiencyBonus=0;
        if (teamEfficiency||Number(teamEfficiency)>=98){ //生产效率必须大于等于98才有绩效标准
          //
            if (accuracyImeliness>=97.5 && accuracyImeliness<99){
                rEfficiencyBonus=500;

            }else if (accuracyImeliness>=99 && accuracyImeliness<100 ){
                rEfficiencyBonus=600;
            }else if (accuracyImeliness==100){
                rEfficiencyBonus=700;
            }

            //赋值绩效奖金标准
            getEditObjectFuZhu("performanceBonusNorm").textbox("setValue",rEfficiencyBonus);
            //生产效率奖金:绩效奖金标准*0.95
            getEditObjectFuZhu("efficiencyBonus").textbox("setValue",rEfficiencyBonus*0.95);
        }
    }

    //5s的规范化奖金------------------------------------------------------------------------------------------------
    //辅助人员-5s的规范化奖金
    function baoZhuangCheJianFuZhuScore5s(newValue) {
        var result=0;
        newValue=newValue?Number(newValue):0;
        //大于或等于85：绩效奖金标准*0.05
        if (newValue>=85){
            var performanceBonusNorm=Number(getEditObjectFuZhu("performanceBonusNorm").textbox("getValue")) //绩效奖金标准
            result=performanceBonusNorm*0.05
        }
        var penalty5s= getEditObjectFuZhu("penalty5s");   //规范化奖金
        penalty5s.textbox("setValue",fomatFloat(result,2));
    }

    //辅助组长-5s的规范化奖金
    function baoZhuangCheJianFuZhuZuZhangScore5s(newValue) {
        var result=0;
        newValue=newValue?Number(newValue):0;
        //大于或等于85：绩效奖金标准*0.05
        if (newValue>=85){
            var performanceBonusNorm=Number(getEditObjectFuZuZuZhang("performanceBonusNorm").textbox("getValue")) //绩效奖金标准
            result=performanceBonusNorm*0.05
        }
        var penalty5s= getEditObjectFuZuZuZhang("penalty5s");   //规范化奖金
        penalty5s.textbox("setValue",fomatFloat(result,2));
    }

    //清洁工、搬运工的规范化奖金
    function baoZhuangCheJianFuZhuZaGongScore5s(newValue) {
        var result=0;
        newValue=newValue?Number(newValue):0;
        //大于或等于85：绩效奖金标准*0.05
        if (newValue>=85){
            var performanceBonusNorm=Number(getEditObjectFuZuZaGong("performanceBonusNorm").textbox("getValue")) //绩效奖金标准
            result=performanceBonusNorm*0.05
        }
        var penalty5s= getEditObjectFuZuZaGong("penalty5s");   //规范化奖金
        penalty5s.textbox("setValue",fomatFloat(result,2));
    }

    //最终绩效计算方式-------------------------------------------------------------------------------------------------
    function totalBaoZhuangFuZhu(newValue) {
        console.log("合计综合绩效")
        //初始效率高点: 注意：js的0相等于空字符串和false，js的1相等于字符串"1"、true;0==false==""   1==true="1" 所以不要去判断了
        if (newValue!= undefined || newValue!= null){
            var efficiencyBonus=getEditObjectFuZhu("efficiencyBonus").textbox("getValue"); //效率奖金
            efficiencyBonus=efficiencyBonus?Number(efficiencyBonus):0;
            var penalty5s=getEditObjectFuZhu("penalty5s").textbox("getValue");       //规范奖金
            penalty5s=penalty5s?Number(penalty5s):0;
            var penaltyBonus=getEditObjectFuZhu("penaltyBonus").textbox("getValue");//质量扣款
            penaltyBonus=penaltyBonus?Number(penaltyBonus):0;
            var attendanceRate=getEditObjectFuZhu("attendanceRate").textbox("getValue"); //出勤率
            attendanceRate=attendanceRate?Number(attendanceRate)/100:1;
            var exceptionBonus=getEditObjectFuZhu("exceptionBonus").textbox("getValue"); //发现异常奖金
            exceptionBonus=exceptionBonus?Number(exceptionBonus):0;
            var illegalFine=getEditObjectFuZhu("illegalFine").textbox("getValue");      //违规扣款
            illegalFine=illegalFine?Number(illegalFine):0;
            var resultMoney=getEditObjectFuZhu("resultMoney");       //绩效奖金
            resultMoney.textbox("setValue",fomatFloat((efficiencyBonus+penalty5s)*attendanceRate+exceptionBonus-penaltyBonus-illegalFine,2))
        }
    }

    function totalBaoZhuangFuZhuZuZhang(newValue) {
        console.log("合计综合绩效")
        //初始效率高点: 注意：js的0相等于空字符串和false，js的1相等于字符串"1"、true;0==false==""   1==true="1" 所以不要去判断了
        if (newValue!= undefined || newValue!= null){
            var efficiencyBonus=getEditObjectFuZuZuZhang("efficiencyBonus").textbox("getValue"); //效率奖金
            efficiencyBonus=efficiencyBonus?Number(efficiencyBonus):0;
            var penalty5s=getEditObjectFuZuZuZhang("penalty5s").textbox("getValue");       //规范奖金
            penalty5s=penalty5s?Number(penalty5s):0;
            var penaltyBonus=getEditObjectFuZuZuZhang("penaltyBonus").textbox("getValue");//质量扣款
            penaltyBonus=penaltyBonus?Number(penaltyBonus):0;
            var attendanceRate=getEditObjectFuZuZuZhang("attendanceRate").textbox("getValue"); //出勤率
            attendanceRate=attendanceRate?Number(attendanceRate)/100:1;
            var exceptionBonus=getEditObjectFuZuZuZhang("exceptionBonus").textbox("getValue"); //发现异常奖金
            exceptionBonus=exceptionBonus?Number(exceptionBonus):0;
            var illegalFine=getEditObjectFuZuZuZhang("illegalFine").textbox("getValue");      //违规扣款
            illegalFine=illegalFine?Number(illegalFine):0;
            var resultMoney=getEditObjectFuZuZuZhang("resultMoney");       //绩效奖金
            resultMoney.textbox("setValue",fomatFloat((efficiencyBonus+penalty5s)*attendanceRate+exceptionBonus-penaltyBonus-illegalFine,2))
        }
    }

    function totalBaoZhuangFuZhuZaGong(newValue) {
        console.log("杂工合计综合绩效")
        //初始效率高点: 注意：js的0相等于空字符串和false，js的1相等于字符串"1"、true;0==false==""   1==true="1" 所以不要去判断了
        if (newValue!= undefined || newValue!= null){
            var efficiencyBonus=getEditObjectFuZuZaGong("efficiencyBonus").textbox("getValue"); //效率奖金
            efficiencyBonus=efficiencyBonus?Number(efficiencyBonus):0;
            var penalty5s=getEditObjectFuZuZaGong("penalty5s").textbox("getValue");       //规范奖金
            penalty5s=penalty5s?Number(penalty5s):0;
            var penaltyBonus=getEditObjectFuZuZaGong("penaltyBonus").textbox("getValue");//质量扣款
            penaltyBonus=penaltyBonus?Number(penaltyBonus):0;
            var attendanceRate=getEditObjectFuZuZaGong("attendanceRate").textbox("getValue"); //出勤率
            attendanceRate=attendanceRate?Number(attendanceRate)/100:1;
            var exceptionBonus=getEditObjectFuZuZaGong("exceptionBonus").textbox("getValue"); //发现异常奖金
            exceptionBonus=exceptionBonus?Number(exceptionBonus):0;
            var illegalFine=getEditObjectFuZuZaGong("illegalFine").textbox("getValue");      //违规扣款
            illegalFine=illegalFine?Number(illegalFine):0;
            var resultMoney=getEditObjectFuZuZaGong("resultMoney");       //绩效奖金
            resultMoney.textbox("setValue",fomatFloat((efficiencyBonus+penalty5s)*attendanceRate+exceptionBonus-penaltyBonus-illegalFine,2))
        }
    }

// 页脚行---------------------------------------------------------------------
    //辅助人员页脚行
    function loadBzFuZhuFooter() {
        console.log("加载页脚行")
        //获取所有的行
        var rows = $('#bzFuZhuRenYuanTable').datagrid("getRows");
        //定义组别变量：以组长名称定义
        //var group={}
        //平均值变量
        var average=[];

        //循环获取组别
        var totalResultMoney=0;
        //辅助人员总人数
        if (rows){
            rows.forEach(function (a) {
                var zuZhangName = a.zuZhangName;//所属组长名称
                //第一次
                if(average.length==0){
                    //num参数是总人数：用于求平均值
                    average.push({"zuZhangName":zuZhangName,"resultMoney":a.resultMoney,num:1});
                }else {
                    //判断是否有组长名称
                    var flag=true;
                    average.forEach(function (b) {
                        var name = b.zuZhangName;
                        if (name==zuZhangName){//若等于证明有了；进行累加最终绩效数据
                            flag=false;
                            b.num=b.num+1;
                            b.resultMoney= Number(a.resultMoney)+Number(b.resultMoney);
                        }
                    })
                    //新增
                    if (flag){
                        average.push({"zuZhangName":zuZhangName,"resultMoney":a.resultMoney,"num":1});
                    }

                }
                //合计
                totalResultMoney=fomatFloat(Number(totalResultMoney)+Number(a.resultMoney),2);
            })

            //处理平均值
            average.forEach(function (a) {
                a.empCode="平均绩效"
                a.zuZhangName=a.zuZhangName
                a.resultMoney=fomatFloat(a.resultMoney/a.num,2);
            })
        }
        //最后往行尾头添加总合计
        average.push({"empCode":"总合计","resultMoney":totalResultMoney});
        //存储辅助人员页脚行
        bzFuZhuRenYuanTableFooter=average;
        //存储辅助人员总合计和人数获取平均值：清洁工和
        console.log("辅助人员总人数：",rows.length)
        bzFuZhuRenYuanTotalResultMoney=fomatFloat(totalResultMoney/rows.length,2);
        //{empCode:'测试1',resultMoney:50000}
        $('#bzFuZhuRenYuanTable').datagrid('reloadFooter',average);

    }

    //辅助组长页脚行
    function loadBzFuZhuZuZhangFooter() {
        //获取所有的行
        let rows = $('#bzFuZhuZuZhangTable').datagrid("getRows");
        //循环获取组别
        let totalResultMoney=0;
        if (rows){
            rows.forEach(function (val) {
                //合计
                totalResultMoney=fomatFloat(totalResultMoney+Number(val.resultMoney),2);
            })
        }
        $('#bzFuZhuZuZhangTable').datagrid('reloadFooter',[{"empCode":"总合计","resultMoney":totalResultMoney}]);
    }

    //清洁工、搬运工页脚行
    function loadBzFuZhuZaGongFooter() {
        //获取所有的行
        let rows = $('#bzFuZhuZaGongTable').datagrid("getRows");
        //循环获取组别
        let totalResultMoney=0;
        if (rows){
            rows.forEach(function (val) {
                //合计
                totalResultMoney=fomatFloat(totalResultMoney+Number(val.resultMoney),2);
            })
        }
        $('#bzFuZhuZaGongTable').datagrid('reloadFooter',[{"empCode":"总合计","resultMoney":totalResultMoney}]);
    }

</script>
</div>